<?php

/*---------Multicart 2.0 Upgradation starts----------*/

$username_flag = 1;
$password_flag = 0;

$currency_selected = "";
 //if (function_exists('session_unregister')) 
    //(isset($_SESSION['SESS_currency_type']))?session_unregister('SESS_currency_type'):session_register('SESS_currency_type');;

if(isset($_POST['currency_type'])) {

    //activateCurrencyType($_POST['currency_type']);
    $currency_type = $_POST['currency_type'];

    $_SESSION['SESS_currency_type'] = $currency_type;

    echo "<script type='text/javascript'> window.location='".$_SERVER['HTTP_REFERER']."';</script>";

}
else {

    if (!isset($_SESSION['SESS_currency_type']) OR $_SESSION['SESS_currency_type'] == "") {

        /*$_SESSION['SESS_currency_type']	= "1";
				$currency_type					= "1";*/
        /*$select_currency_id = "SELECT ncurrency_id FROM ".$tableprefix."currency_master WHERE vactive = 'Y'";
				$result_currency_id = mysql_query($select_currency_id) or die(mysql_error());
				$currency_rowid = mysql_fetch_assoc($result_currency_id);
				$_SESSION['SESS_currency_type']	= $currency_rowid['ncurrency_id'];
				$currency_type = $currency_rowid['ncurrency_id'];*/

        $select_currency_id = "SELECT ncurrency_id,vcurrency_code FROM ".$tableprefix."currency_master WHERE vactive = 'Y'";
        $result_currency_id = mysql_query($select_currency_id) or die(mysql_error());
        $currency_rowid = mysql_fetch_assoc($result_currency_id);
        $_SESSION['SESS_currency_type']	= $currency_rowid['vcurrency_code'];
        $currency_type = $currency_rowid['vcurrency_code'];

    }
    /*$select_currency_id = "SELECT ncurrency_id FROM ".$tableprefix."currency_master WHERE vactive = 'Y'";
			$result_currency_id = mysql_query($select_currency_id) or die(mysql_error());
			$currency_rowid = mysql_fetch_assoc($result_currency_id);

			$currency_type = $currency_rowid['ncurrency_id'];*/
}


/*---------Multicart 2.0 Upgradation ends----------*/


if(isset($_POST['loginbox'])) {

    $txtUserName = $_POST["txtUserName"];

    $txtPassword = $_POST["txtPassword"];
    /*$sql=" SELECT user_id,user_name,password FROM ".$tableprefix."users WHERE user_name='".addslashes($txtUserName)."' AND password = '".addslashes(md5($txtPassword))."' AND deleted = 'N'";
	$result=mysql_query($sql) or die(mysql_error());
	if(mysql_num_rows($result) > 0 ){
			$row = mysql_fetch_array($result);
			$message="Success!";
			$_SESSION["sess_username"] = $row["user_name"];
			$_SESSION["sess_userid"] = $row["user_id"];*/

    /*----------Multicart 2.0 Upgradation starts-----------*/


    /*---------Checking the password----------------*/

    $select_password = "SELECT password
                              FROM ".$tableprefix."users
                             WHERE LOWER(user_name) = ".strtolower(GetSQLValueString($txtUserName,"text"))."
                               AND deleted = 'N'";

    $result_password = mysql_query($select_password) or die(mysql_error());
    if(mysql_num_rows($result_password) > 0) {

        $password_row = mysql_fetch_assoc($result_password);

        if(GetSQLValueString($password_row['password'],"text") != GetSQLValueString(md5($txtPassword),"text")) {

            //$messagelog = "Invalid password !!";
            $password_flag = 1;

        }


    }

    //else
    //{

    /*---------Checking the username----------------*/

    $select_username = "SELECT user_name FROM ".$tableprefix."users
							WHERE password = ".GetSQLValueString(md5($txtPassword),"text").
            " AND deleted = 'N'";

    $result_username = mysql_query($select_username) or die(mysql_error());
    if(mysql_num_rows($result_username) > 0) {

        while($username_row = mysql_fetch_array($result_username)) {

            if(strtolower(GetSQLValueString($username_row['user_name'],"text")) == strtolower(GetSQLValueString($txtUserName,"text"))) {
                $username_flag = 0;
            }

            /*if(GetSQLValueString($username_row['user_name'],"text") != GetSQLValueString($txtUserName,"text"))
				{
				
					$messagelog = "Invalid username !!";
					$username_flag = 1;
				
				}
				else
				{
				
					$username_flag = 0;
				
				}*/
        }


    }

    if($username_flag == 1 && $password_flag == 0) {
        $messagelog = INVALID_USERNAME_TEXT;
    }

    if($username_flag == 1 && $password_flag == 1) {
        $messagelog = INVALID_PASSWORD_TEXT;
    }

    //}

    if($username_flag != 1 && $password_flag != 1) {

        $sql=" SELECT user_id,user_name,password FROM ".$tableprefix."users
				WHERE user_name='".addslashes($txtUserName)."' AND password = '".addslashes(md5($txtPassword))."' AND deleted = 'N'";
        $result=mysql_query($sql) or die(mysql_error());
        if(mysql_num_rows($result) > 0 ) {
            $row = mysql_fetch_array($result);
            $message="Success!";
            $_SESSION["sess_username"] = $row["user_name"];
            $_SESSION["sess_userid"] = $row["user_id"];

            /*---------------Multicart 2.0 Upgradation------------------*/

            /*-------function call to manage the different sessions--------*/

            manageSession(3);

            /*---------------Multicart 2.0 Upgradation------------------*/

            if(!isVisitorCartEmpty(session_id())) {
                mergeVisitorCartToUserCart(session_id(),$row["user_id"]);
            }
            if($action!= "") {
                if($action == "checkout") {
                    echo "<script>location.href='viewcart.php';</script>";
                    //header("Location:viewcart.php");
                    exit;
                }
            }
            else {

                /*--------Multicart 2.0 starts-----------*/

                /*echo "<script>location.href='usermain.php';</script>";*/

                $currentPage=GetCurrentPageName();

                $referer = $_SERVER['HTTP_REFERER'];

                echo "<script>location.href='".$referer."';</script>";

                /*--------Multicart 2.0 ends-----------*/

                //header("Location:usermain.php");
                exit;
            }

        }
        else {
            $messagelog = INVALID_USERNAME_PASSWORD_TEXT;

        }

    }

    /*----------Multicart 2.0 Upgradation ends-----------*/

}else if(isset($_POST['newuser'])) {
    echo "<script>location.href='register.php';</script>";
    exit;



}
?>
<script language="javascript">
    function clearText(thefield,id){
        if (thefield.defaultValue==thefield.value)
            thefield.value = ""
        identity=document.getElementById(id);
        identity.className='textfield';
    }

    function openuserhelp()
    {

        var url = './help/userhelp/index.html'
        window.open(url,"Help","scrollbars=yes");
    }

</script>
<div id="wrapper">

    <!-- Header Styles Start -->
    <div id="header">


        <div class="headerleft">

            <div class="logo"><a href="<?php echo SITE_URL?>/index.php">

<?php

if(basename($_SERVER['PHP_SELF']) == "payment.php" || basename($_SERVER['PHP_SELF']) == "yourpay_payment.php") {
    ?>

                    <img src="<?php echo SECURE_SITE_URL?>/banners/<?php echo $logoimage?>" alt="" width="202" height="97" border="0" />

    <?php

}
else {

    ?>

                    <img src="<?php echo $logofolder?>/<?php echo $logoimage?>" alt=""  border="0" />


                        <?php

                    }

                    ?>

                </a></div>

        </div>

        <div class="headerright">

                    <?php

                    if(isset($_SESSION["sess_userid"]) and $_SESSION["sess_userid"]!= "") {
    ;
}
else if(basename($_SERVER['PHP_SELF'])!= "login.php" ) {

                        ?>
            <div class="login_sec">
                <form name="frmLogin" action="" method="POST" onSubmit="return checkLoginForm();">


                    <h6><?php echo USER_LOGIN_TEXT;?><span><?php echo $messagelog;?></span></h6>


                    <input name="txtUserName" type="text"  class="textfield2" value="<?php echo USERNAME_TEXT;?>" size="20"  onfocus="clearText(this,'txtUserName');"  id="txtUserName"/>


                    <input name="txtPassword" type="password"  class="textfield2" value="<?php echo PASSWORD_TEXT;?>" size="20"  onfocus="clearText(this,'txtPassword');" id="txtPassword"/>

                    <input name="loginbox" type="submit" class="button" value=" <?php echo GO_BUTTON;?>" />

                </form>


                <p><a href="forgotpassword.php"><?php echo FORGOTPASSWORD_LINK_TEXT;?></a></p>
                <div class="clear"></div>
            </div>
    <?php } ?>
<?php
if($_SESSION["sess_userid"] != "") {

    $select_user_name = "SELECT first_name,last_name FROM ".$tableprefix."users WHERE user_id = ".$_SESSION["sess_userid"];

    $result_user_name = mysql_query($select_user_name) or die(mysql_error());

    if(mysql_num_rows($result_user_name) > 0) {

        $user_name_row = mysql_fetch_assoc($result_user_name);

        ?>
            <div class="login_sec2">
                <h1>
	<?php echo WELCOME_TEXT;?>&nbsp; <?php echo $user_name_row['first_name']?>&nbsp;<?php echo $user_name_row['last_name']?><br />

                </h1>

                <a href="<?php echo SITE_URL?>/myaccount.php" class="my_account_login_btt">My Account</a>
                &nbsp;
                <a href="<?php echo SITE_URL?>/logout.php" class="my_account_login_btt">Logout</a>


                <div class="clear"></div>
            </div>

                    <?php

                }


            }
?>

                    <?php
if(basename($_SERVER['PHP_SELF'])== "login.php" ) {
    ?>

            <div class="login_sec3"> &nbsp;</div>

    <?php } ?>


<?php
if(strstr($_SERVER['SCRIPT_FILENAME'],'index.php') == TRUE) {
    $link_selected_index = "activelink";
            }
            elseif(strstr($_SERVER['SCRIPT_FILENAME'],'categorydetail.php') == TRUE) {
                $link_selected_category = "activelink";
            }
            elseif(strstr($_SERVER['SCRIPT_FILENAME'],'viewcart.php') == TRUE) {
                $link_selected_cart = "activelink";
            }
elseif(strstr($_SERVER['SCRIPT_FILENAME'],'postfeedback.php') == TRUE) {
                $link_selected_feedback = "activelink";
            }
            elseif(strstr($_SERVER['SCRIPT_FILENAME'],'faq.php') == TRUE) {
                $link_selected_faq = "activelink";
}
elseif(strstr($_SERVER['SCRIPT_FILENAME'],'about_us.php') == TRUE) {
    $link_selected_aboutus = "activelink";
            }
elseif(strstr($_SERVER['SCRIPT_FILENAME'],'contact_us.php') == TRUE) {
    $link_selected_contactus = "activelink";


            }
            ?>
            <div class="header_inneright">
                <div class="cart_section">

                    <h4><a href="<?php echo SITE_URL?>/viewcart.php"><?php echo CART_TEXT;?> <span> <?php if($_SESSION["sess_userid"] != "") {
                echo GetUserCartCount($_SESSION["sess_userid"]);
            }  else {
                echo  GetVisitorCartCount(session_id());
            } ?> <?php echo CART_ITEMS_COUNT_TEXT;?></span></a></h4>

                </div>
                <div class="search_topheader">&nbsp;</div>
                <div class="topnavsec" style="float:right; width:380px;margin-bottom:5px; ">

                    <div  style="width:180px; height:28px; margin:3px 0 0 10px; float:left; ">
            <?php
            $sqlSM = "SELECT title,logo,link
        FROM ".$tableprefix."social_media
            WHERE active='Y'";
            $resultSM = mysql_query($sqlSM) or die(mysql_error());

            if(mysql_num_rows($resultSM) != 0) {
                ?>
                        <div  style="float:left; clear:left;  ">
                <?php
                while($rowSM =  mysql_fetch_object($resultSM)) {
                    $smLInk = $rowSM->link != '' ? $rowSM->link : '#';
                    ?>
                            <a href="<?php echo $smLInk; ?>" target="_blank" style="margin:0 5px 0 0;  float:left; padding:0; " title="<?php echo $rowSM->title; ?>" >&nbsp;&nbsp;<img  style="float:left; "src="<?php echo SITE_URL?>/social_media/<?php echo $rowSM->logo; ?>" /></a>
        <?php
    }
    ?>
                        </div>
    <?php
}
?>


                    </div>





                        <?php
                        if($adminCurrency['currency_code']!='') {
                            $currency_code	= $adminCurrency['currency_code'];
                        }
else {
                                $currency_code = 'USD';
                            }

                            ?>
                    <input type="hidden" value="<?php echo $currency_code;?>" name="currency_type">
<?php
                            if(getSettingsValue('enable_multicurrency') == 'Y') {
                                ?>
                    <form name="frmCurrencyType" method="post">


                        <div class="topnavsec1" style="width:180px;">Currency &nbsp;&nbsp;


                            <select name="currency_type" class="topsearch_fld" onChange="Javascript:document.frmCurrencyType.submit();">
    <?php

    $currency_type	=	$_SESSION['SESS_currency_type'];

    if($currency_type=='') {
        $currency_type='USD';
                        }
                        $select_currency = "SELECT vcurrency_code,ncurrency_id,vcurrency_name FROM ".$tableprefix."currency_master WHERE vactive = 'Y' ORDER BY vcurrency_name";
                        $result_currency = mysql_query($select_currency) or die(mysql_error());

                        while($currency_row = mysql_fetch_array($result_currency)) {

                            if($currency_type == $currency_row['vcurrency_code']) {

                                $currency_selected = "selected";

                            }
        else {
                                $currency_selected = "";
                            }


        ?>
                                <option value="<?php echo $currency_row['vcurrency_code']?>" <?php echo $currency_selected?>><?php echo $currency_row['vcurrency_name']?></option>

        <?php

    }

                                    ?>
                            </select>



                        </div>
                    </form>
                                    <?php } ?>
                    <!--
                    <div class="topnavsec2" style="float:right;padding-top:5px;" >
                    <a href="<?php echo SITE_URL?>/contact_us.php" id="<?php echo $link_selected_index?>">Site Feedback</a>
                    <a href="<?php echo SITE_URL?>/contact_us.php" id="<?php echo $link_selected_index?>">Contact Us </a>
                    <a href="<?php echo SITE_URL?>/terms_conditions.php" id="<?php echo $link_selected_index?>"> Terms &amp; Conditions |</a>
                    </div>-->
                </div>
                <div class="clear"></div>
            </div>

            <div class="clear"></div>
        </div>

        <div class="clear"></div>
    </div>
    <!-- Header Styles End -->



    <!-- Top Nav Section Start -->
    <div class="navtop">

        <ul>
            <li><a href="<?php echo SITE_URL?>/index.php" class="<?php echo $link_selected_index?>"><?php echo HOME_LINK;?></a></li>
            <li><a href="<?php echo SITE_URL?>/categorydetail.php" class="<?php echo $link_selected_category?>"><?php echo CATALOG_LINK;?></a></li>
            <li><a href="<?php echo SITE_URL?>/viewcart.php" class="<?php echo $link_selected_cart?>"><?php echo VIEW_CART_LINK;?></a></li>
            <li><a href="<?php echo SITE_URL?>/allseller.php"><?php echo SELLER_LINK;?></a></li>
<?php
$enableAffiliate = getSettingsValue('enable_affiliates');
if($enableAffiliate == 'Y') {
    ?>
            <li><a href="<?php echo SITE_URL?>/affiliates/login.php"><?php echo AFFILIATES_LINK;?></a></li>
    <?php
}
?>
            <li><a href="<?php echo SITE_URL?>/about_us.php" class="<?php echo $link_selected_aboutus;?>"><?php echo ABOUT_LINK;?></a></li>
            <li><a href="<?php echo SITE_URL?>/faq.php" class="<?php echo $link_selected_faq?>"><?php echo FAQ_LINK;?></a></li>
            <li><a href="<?php echo SITE_URL?>/site-feedback.php" class="<?php echo $link_selected_feedback?>"><?php echo SITE_FEEDBACK_LINK;?></a></li>
            <li><a href="" style="cursor:pointer" onClick="openuserhelp();"><?php echo HELP_LINK;?></a></li>

        </ul>

        <div class="featuredproduct_btn"><a href="<?php echo SITE_URL?>/index.php?featured=N"><?php echo NEW_PRODUCTS_TEXT; ?></a></div>
        <div class="clear"></div>
    </div>
    <!-- Top Nav Section End -->




    <!-- Content Area Start -->

    <div class="contentarea" <?php if($newThemeStyle!=''){?> style="<?php echo $newThemeStyle?>" <?php }?>>

        <!-- content Area Left start -->
        <div class="contentarea_left" <?php if($newThemeStyle!=''){?> style="background-color:#ccc;" <?php }?>>
            <div class="seller_imgndetails">
                <div class="seller_img">
<?php echo $imageurl;?>
                </div>
                <div class="seller_details">
                    <table width="87%"  border="0" cellspacing="0" cellpadding="0" class="sllr_tble" align="center">
                        <tr>
                            <td valign="top" align="left"><p class="seller_name"><?php echo $txtArtistFullName;?></p></td>
                        </tr>
                        <tr>
                            <td valign="top" align="left"><p class="seller_name"><?php echo $txtArtistCompany;?></p></td>
                        </tr>
                        <tr>
                            <td valign="top" align="left"><?php echo $txtArtistState;?></td>
                        </tr>
                        <tr>
                            <td valign="top" align="left"><?php echo  $txtArtistCountry;?></td>
                        </tr>
<?php   $sellerrating	= GetSellerAverageRating($artistid); ?>

<?php if($sellerrating>0) { ?>
                        <tr>
                            <td valign="top" align="left" class="ratings1">

                                <div> <div class="rating_<?php echo $sellerrating ;?>"></div></div></td>
                        </tr>
    <?php } ?>
                        <tr>
                            <td valign="top" align="left">
                                <div class="seller_fedbk_btn">
                                    <a href="<?php echo SITE_URL?>/artistfeedbacks.php?artistid=<?php echo $artistid?>"><span><?php echo VIEW_FEEDBACK_LINK;?></span></a>

                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top" align="left">
                                <div class="seller_contact_btn">
                                    <a href="<?php echo SITE_URL?>/sendmessagetoseller.php?artistid=<?php echo $artistid;?>" ><span><?php echo CONTACT_SELLER_LINK;?></span></a>
                                </div>
                            </td>
                        </tr>

                    </table>
                </div>
                <div class="clear"></div>
            </div>
<?php
include_once("includes/categorylist_seller.php");
?>			
            <div class="clear"></div>
        </div>
        <!-- content Area Left End -->


        <!-- content Area Right start -->
        <div class="contentarea_right">
